<script setup lang="ts">
import {inject, onBeforeMount, onMounted, reactive} from "vue";
import {ElMessage} from "element-plus";
onBeforeMount(()=>{
  ss.connect()
})
const ss = inject('socket');
onMounted(() => {
  ss.on("connected",afterConnect)
  ss.on('message', onMessage)
})
const afterConnect =  () => {
  console.log('socket connect success')
}
const onMessage = (data: any) => {
  if (data.app === 'system' && data.operation === 'connect_success') {
    //登陆成功
    ElMessage({
      message: 'socket监听成功',
      type: 'success',
    })
  }
}
</script>
<template>
  <RouterView/>
</template>

<style scoped>

</style>
